import { ApiProperty, getSchemaPath, ApiExtraModel } from '@midwayjs/swagger';
import { Rule, RuleType } from '@midwayjs/validate';
import { ApiRes, Gender, PaginationDto } from '.';

export class VisitorIdRequired {
  @ApiProperty({ description: '访客id', required: true })
  @Rule(RuleType.number().required().error(new Error('访客id不能为空')))
  id: number;
}

export class VisitorAddDto {
  @ApiProperty({ description: '访客姓名', required: true })
  @Rule(RuleType.string().required().error(new Error('访客姓名不能为空')))
  name: string;

  @ApiProperty({ description: '访客手机号', required: true })
  @Rule(RuleType.number().required().error(new Error('访客手机号不能为空')))
  phone: number;

  @ApiProperty({ description: '来访时间', required: true })
  @Rule(RuleType.string().required().error(new Error('来访时间不能为空')))
  visitDate: string;

  @ApiProperty({
    description: '性别0女1男',
    default: Gender.Man,
    required: true,
  })
  @Rule(RuleType.string().required().error(new Error('性别不能为空')))
  gender: string;

  @ApiProperty({ description: '房屋id', required: true })
  @Rule(RuleType.number().required().error(new Error('房屋id不能为空')))
  houseId:number
}
export class VisitorItemDto extends VisitorAddDto {
  @ApiProperty({ description: '访客id' })
  id: number;

  @ApiProperty({ description: '小区名称' })
  pointName: string;

  @ApiProperty({ description: '小区楼栋信息' })
  building: string;

  @ApiProperty({ description: '小区房间信息' })
  room: string;

  @ApiProperty({ description: '业主姓名' })
  userName: string;

  @ApiProperty({ description: '通行证url' })
  url: string;

  @ApiProperty({ description: '状态：1生效中0已失效' })
  status: string;
}

@ApiExtraModel(VisitorItemDto)
export class VisitorItemRes {
  @ApiProperty({
    type: 'array',
    items: {
      $ref: getSchemaPath(VisitorItemDto),
    }
  })
  list: VisitorItemDto[];
  @ApiProperty({ type: PaginationDto, description: '分页' })
  pagination: PaginationDto;
}


export class VisitorItemResDto extends ApiRes<VisitorItemRes>(VisitorItemRes) {}
